#include <stdio.h>
#include <stdlib.h>
#include "ImageFmtc.h"

int main(int argc, char **argv)
{
unsigned char (*image)[3] = NULL;
int w, h;
int x, y;

if (argc != 2) {
puts("Usage: myprog <something.bmp>");
return EXIT_FAILURE;
}

if (ReadBMP(argv[1], &image, &w, &h) != 0) {
puts("Error: I couldn't read that BMP file!");
free(image);
return EXIT_FAILURE;
}

printf("Pixels in form (x, y, r, g, b)\n");

for (y=0; y < h; ++y) {
    for (x=0; x < w; ++x) {
	int ofs = y*w+x;
	printf("(%d, %d, %d, %d, %d)\n",
	x, y,
	image[ofs][0], image[ofs][1], image[ofs][2]);
      }
  }

free(image);
return 0;
}
